<template>
  <div>
    <el-form v-model="orderTypeForm" label-width="120px">
      <el-form-item label="物品类型名称">
        <el-input v-model="orderTypeForm.name"/>
      </el-form-item>

      <el-form-item label="默认重量(千克)">
        <el-input v-model="orderTypeForm.defaultWeight" type="number"/>
      </el-form-item>
      <el-form-item label="默认体积(方)">
        <el-input v-model="orderTypeForm.defaultVolume" type="number"/>

      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="orderTypeForm.remark" type="textarea"/>
      </el-form-item>
      <el-form-item label="车辆类型">
        <el-select v-model="orderTypeForm.truckTypeIds" multiple placeholder="请选择">
          <el-option
            v-for="item in truckType"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="状态">
        <el-radio v-model="orderTypeForm.status" :label="1" border>正常</el-radio>
        <el-radio v-model="orderTypeForm.status" :label="0" border>禁用</el-radio>
      </el-form-item>
    </el-form>
    <el-button type="primary" @click="addOrderType">添加</el-button>
  </div>
</template>

<script>
import orderType from '@/api/base/orderType/index'

export default {
  name: 'add',
  data() {
    return {
      truckType: [],
      orderTypeForm: {
        name: '',
        defaultWeight: '',
        defaultVolume: '',
        remark: '',
        truckTypeIds: [],
        status: 1
      }
    }
  }, methods: {
    addOrderType() {
      orderType.addOrderType(this.orderTypeForm).then(data => {
        this.$message({
          type: 'success',
          message: '商品类型添加成功!',
          showClose:true
        });
        this.$router.push({path:'/orderType-index'})
      })
    },
    getAllTruckType() {
      orderType.getAllTruckType().then(data => {
        this.truckType = data.data
      })
    }
  }, mounted() {
    this.getAllTruckType()
  }
}
</script>

<style scoped>

</style>
